package com.treasure.service.collocate.controller;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.collocate.service.BankConfigService;
import com.treasure.service.constant.Status;
import com.treasure.service.dto.TBankConfigDto;
import com.treasure.service.dto.TCreditCardDto;
import com.treasure.service.enums.CodeEnum;
import com.treasure.service.result.PageResult;
import com.treasure.service.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 获取银行相关配置信息
 * @version 1.0
 * @author panxinwen 2018/10/30 10:32
 * @Copyright © 2015 | 武汉京航科技有限公司 Email:19919866605@163.com
 * */
@Api(value = "银行或渠道商配置信息",description = "银行或渠道商配置信息")
@RestController
@RequestMapping("/bankConfig/v1")
public class BankConfigController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private BankConfigService bankConfigService;

    @ApiOperation(value = "获取银行或渠道配置列表", notes = "获取银行或渠道配置列表")
    @PostMapping("/getBankConfigList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "頁碼", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每頁顯示數量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "recommend", value = "是否首页显示（0-否 1-是）", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "渠道状态（0-禁用 1-启用）", required = true, dataType = "int", paramType = "query")
    })
    @LogInfo(log = "获取银行或渠道配置列表",isPrint = true)
    public ResponseEntity getBankConfigList(@RequestParam(value = "pageSize") Integer pageSize,
                                            @RequestParam(value = "pageNum") Integer pageNum,
                                            @RequestParam(value = "recommend",required = false) Integer recommend,
                                            @RequestParam(value = "recommend",required = false) Integer status
                                            ){

        PageResult<List<TBankConfigDto>> result = bankConfigService.getBankConfigList(pageSize,pageNum,recommend,status);

        return ResponseEntity.ok(new ResponseResult(CodeEnum.SUCCESS,result));

    }

    @ApiOperation(value = "获取热门信用卡列表", notes = "获取热门信用卡")
    @PostMapping("/getCreditList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "頁碼", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每頁顯示數量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "渠道状态（0-禁用 1-启用）", required = true, dataType = "int", paramType = "query")
    })
    @LogInfo(log = "获取热门信用卡列表",isPrint = true)
    public ResponseEntity getCreditList(@RequestParam(value = "pageSize") Integer pageSize,
                                            @RequestParam(value = "pageNum") Integer pageNum,
                                            @RequestParam(value = "recommend",required = false) Integer status
                                            ){

        PageResult<List<TCreditCardDto>> result = bankConfigService.getCreditList(pageSize,pageNum,status);
        return ResponseEntity.ok(new ResponseResult(CodeEnum.SUCCESS,result));

    }

}
